//
// Decompiled by Jadx - 487ms
//
package fn;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import androidx.constraintlayout.widget.i;
import b.c;
import de.robv.android.xposed.XC_MethodHook;
import dj.d;
import fk.b;
import fp.m;
import fp.o;
import fq.n;
import fq.q;
import fq.r;
import gf.af;
import gf.f;
import gf.j;
import gf.p;
import gf.u;
import gf.y;
import java.net.Proxy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import me.plusne.HookMain;
import me.plusne.NativeTools;
import me.plusne.common.Json.JsonHookStatic;
import me.plusne.common.Json.Login.JsonLoginUserInfo;
import o.a;
import okhttp3.x;
import org.luckypray.dexkit.DexKitBridge;
import p.d;
import r.g;

public final class s extends XC_MethodHook {
    public final x a;

    public s(HookMain.b bVar) {
        this.a = bVar;
    }
    // ga QQ
    // gf 微信
    // gc Soul
    // fp 抖音
    // fq 抖音
    // fs
    public final void afterHookedMethod(XC_MethodHook.MethodHookParam methodHookParam) {
        a annotation;
        if (x.br) {
            return;
        }
        x.br = true;
        try {
            System.loadLibrary("plusne");
            NativeTools.i(y.by.getModulePath());
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
        JsonHookStatic jsonHookStatic = y.by;
        jsonHookStatic.setRunTime(System.currentTimeMillis());
        jsonHookStatic.setApplication((Application) methodHookParam.thisObject);
        ClassLoader classLoader = jsonHookStatic.getApplication().getClassLoader();
        y.bz = classLoader;
        jsonHookStatic.setClassLoader(classLoader);
        Application application = jsonHookStatic.getApplication();
        if (application != null) {
            j.y(application.getResources());
        }
        i.cs(jsonHookStatic.getApplication());
        i.dp(NativeTools.b());
        d dVar = new d();
        dq.a m = dq.a.m();
        m.getClass();
        String str = ed.d.a;
        x.a aVar = m.j;
        aVar.getClass();
        aVar.c.add(dVar);
        dq.a m2 = dq.a.m();
        Proxy proxy = Proxy.NO_PROXY;
        m2.getClass();
        if (proxy != null) {
            x.a aVar2 = m2.j;
            if (!kotlin.jvm.internal.i.a(proxy, aVar2.m)) {
                aVar2.ad = null;
            }
            aVar2.m = proxy;
            x.a aVar3 = dq.a.m().j;
            TimeUnit timeUnit = TimeUnit.MILLISECONDS;
            aVar3.af(60000L, timeUnit);
            dq.a.m().j.ag(60000L, timeUnit);
            dq.a.m().j.ae(60000L, timeUnit);
            dq.a m3 = dq.a.m();
            m3.getClass();
            x.a aVar4 = m3.j;
            aVar4.af(60000L, timeUnit);
            aVar4.ag(60000L, timeUnit);
            aVar4.ae(60000L, timeUnit);
            dq.a.m().h = 3;
            try {
                fl.a aVar5 = new fl.a(new b(jsonHookStatic.getApplication()).getWritableDatabase());
                jsonHookStatic.setDb(new fl.b(((x.b) aVar5).a, c.Session, ((x.b) aVar5).b));
            } catch (Exception e2) {
                j.bi(new Object[]{"sqlite ->" + e2.getMessage()});
                e2.printStackTrace();
            }
            JsonLoginUserInfo i = g.i(b.i("userInfo"));
            if (i != null) {
                y.by.setUserInfo(i);
            }
            p.a.c(false);
            if (!x.bs) {
                x.bs = true;
                StringBuilder sb = new StringBuilder("已加载模块[");
                JsonHookStatic jsonHookStatic2 = y.by;
                sb.append(jsonHookStatic2.getMainVersionName());
                sb.append("(");
                sb.append(jsonHookStatic2.getMainVersionCode());
                sb.append(")] ");
                sb.append(jsonHookStatic2.getLpparam().packageName);
                j.bi(new Object[]{sb.toString()});
            }
            JsonHookStatic jsonHookStatic3 = y.by;
            jsonHookStatic3.setUUID(b.i("uuid"));
            if (TextUtils.isEmpty(jsonHookStatic3.getUUID())) {
                jsonHookStatic3.setUUID(UUID.randomUUID().toString());
                b.m(jsonHookStatic3.getUUID(), "uuid");
            }
            if (jsonHookStatic3.getPre().equals("SOUL")) {
                fo.c.k = true;
            }
            jsonHookStatic3.setBridge(jsonHookStatic3.getPre().equals("SOUL") ? DexKitBridge.create(jsonHookStatic3.getClassLoader(), true) : DexKitBridge.create(jsonHookStatic3.getLpparam().appInfo.sourceDir));
            long currentTimeMillis = System.currentTimeMillis();
            ArrayList arrayList = new ArrayList();
            arrayList.add(gf.x.class);
            arrayList.add(p.class);
            arrayList.add(u.class);
            arrayList.add(f.class);
            arrayList.add(af.class);
            androidx.activity.b.w(arrayList, gf.d.class, gf.j.class, gf.w.class, gf.ab.class);
            androidx.activity.b.w(arrayList, gf.ah.class, gf.e.class, gf.ag.class, gf.b.class);
            androidx.activity.b.w(arrayList, gf.ad.class, gf.a.class, gf.h.class, gf.k.class);
            androidx.activity.b.w(arrayList, gf.l.class, gf.i.class, gf.t.class, gf.z.class);
            androidx.activity.b.w(arrayList, gf.ac.class, gf.ae.class, gf.y.class, gf.c.class);
            androidx.activity.b.w(arrayList, gf.v.class, gf.g.class, fp.s.class, fp.b.class);
            androidx.activity.b.w(arrayList, fp.z.class, fp.e.class, fp.f.class, fp.w.class);
            androidx.activity.b.w(arrayList, fp.d.class, fp.ab.class, fp.g.class, fp.a.class);
            androidx.activity.b.w(arrayList, fp.v.class, o.class, fp.x.class, fp.t.class);
            androidx.activity.b.w(arrayList, fp.j.class, fp.u.class, m.class, fp.k.class);
            androidx.activity.b.w(arrayList, fq.k.class, fq.b.class, q.class, fq.e.class);
            androidx.activity.b.w(arrayList, fq.f.class, fq.o.class, fq.d.class, r.class);
            androidx.activity.b.w(arrayList, fq.g.class, fq.a.class, n.class, fq.j.class);
            androidx.activity.b.w(arrayList, fq.p.class, fq.l.class, fq.h.class, fq.m.class);
            androidx.activity.b.w(arrayList, fq.i.class, gc.br.class, gc.cf.class, gc.a.class);
            androidx.activity.b.w(arrayList, gc.ck.class, gc.aw.class, gc.bl.class, gc.bv.class);
            androidx.activity.b.w(arrayList, gc.bq.class, gc.bf.class, gc.bi.class, gc.bx.class);
            androidx.activity.b.w(arrayList, gc.bz.class, gc.bm.class, gc.bo.class, gc.at.class);
            androidx.activity.b.w(arrayList, gc.b.class, gc.by.class, gc.bp.class, gc.be.class);
            androidx.activity.b.w(arrayList, fs.b.class, fs.a.class, ft.a.class, ft.b.class);
            androidx.activity.b.w(arrayList, fz.c.class, fz.a.class, fz.b.class, fv.b.class);
            androidx.activity.b.w(arrayList, fv.a.class, fv.d.class, fv.c.class, fu.b.class);
            androidx.activity.b.w(arrayList, fu.a.class, fu.d.class, fu.c.class, gh.b.class);
            androidx.activity.b.w(arrayList, gh.a.class, gi.a.class, gi.d.class, gi.c.class);
            androidx.activity.b.w(arrayList, gi.e.class, gi.f.class, gg.a.class, gg.b.class);
            androidx.activity.b.w(arrayList, gg.c.class, fx.a.class, fx.b.class, fx.c.class);
            androidx.activity.b.w(arrayList, fy.g.class, fy.c.class, fy.i.class, fy.d.class);
            androidx.activity.b.w(arrayList, fy.a.class, fy.j.class, fy.e.class, fy.h.class);
            androidx.activity.b.w(arrayList, fw.c.class, fw.b.class, fw.d.class, fr.a.class);
            androidx.activity.b.w(arrayList, fr.b.class, gd.b.class, gd.a.class, gd.c.class);
            androidx.activity.b.w(arrayList, ge.g.class, ge.c.class, ge.d.class, ge.q.class);
            androidx.activity.b.w(arrayList, ge.p.class, ge.o.class, ge.b.class, ge.f.class);
            androidx.activity.b.w(arrayList, ge.e.class, ga.h.class, ga.i.class, ga.b.class);
            androidx.activity.b.w(arrayList, ga.j.class, ga.f.class, ga.a.class, ga.d.class);
            arrayList.add(ga.c.class);
            arrayList.add(gb.a.class);
            arrayList.sort(new x.a());
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                Class cls = (Class) it.next();
                try {
                    if (cls.isAnnotationPresent(a.class) && (annotation = cls.getAnnotation(a.class)) != null && annotation.value().equals(jsonHookStatic3.getPre())) {
                        if (!jsonHookStatic3.isExpire() && jsonHookStatic3.getHookData() != null && !jsonHookStatic3.getHookData().isEmpty() && x.bv()) {
                            x.bt++;
                            ((x) cls.newInstance()).a();
                        }
                        if (annotation.init()) {
                            x.bt++;
                            ((x) cls.newInstance()).a();
                        }
                    }
                } catch (IllegalAccessException | InstantiationException e3) {
                    e3.printStackTrace();
                }
            }
            if (jsonHookStatic3.getBridge() != null) {
                jsonHookStatic3.getBridge().close();
            }
            j.bi(new Object[]{"HookInit", (System.currentTimeMillis() - currentTimeMillis) + " ms"});
            JsonHookStatic jsonHookStatic4 = y.by;
            jsonHookStatic4.setHandlerThread(new p());
            jsonHookStatic4.getHandlerThread().start();
            jsonHookStatic4.setHandler(new Handler(jsonHookStatic4.getLooper(), jsonHookStatic4.getHandlerThread()));
            jsonHookStatic4.setExecutorService(Executors.newSingleThreadScheduledExecutor());
            jsonHookStatic4.getExecutorService().scheduleAtFixedRate(new p.e(), 3L, 3600L, TimeUnit.SECONDS);
            this.a.getClass();
            try {
                Application application2 = jsonHookStatic4.getApplication();
                kotlin.jvm.internal.i.g(application2, "context");
                Context applicationContext = application2.getApplicationContext();
                dj.k kVar = do.b.h;
                dj.l lVar = do.b.b;
                com.tonyodev.fetch2core.h hVar = do.b.j;
                dj.f fVar = do.b.i;
                kotlin.jvm.internal.i.b(applicationContext, "appContext");
                com.tonyodev.fetch2core.b bVar = new com.tonyodev.fetch2core.b(applicationContext, com.tonyodev.fetch2core.g.m(applicationContext));
                dj.n nVar = do.b.f;
                if (hVar instanceof com.tonyodev.fetch2core.h) {
                    hVar.a = false;
                    if (kotlin.jvm.internal.i.a(hVar.b, "fetch2")) {
                        hVar.b = "neDownload";
                    }
                } else {
                    hVar.a = false;
                }
                kotlin.jvm.internal.i.b(applicationContext, "appContext");
                jsonHookStatic4.setFetch(d.a.a(new dj.e(applicationContext, "neDownload", 3, 2000L, kVar, lVar, hVar, true, true, fVar, true, bVar, nVar, 300000L, true, -1, true)));
                return;
            } catch (Throwable th) {
                th.printStackTrace();
                return;
            }
        }
        throw new NullPointerException("mProxy == null");
    }
}
